
(function () { 
	Codestrong.ui.CreateSearchLecture = function () {

//var LectureMain = function() {
	var aps='';
	var spacebutton=1,sizebutton=150
	if(Ti.Platform.osname== 'android') {
  		 Titanium.include('../globals.js');
  		
  		 aps='../';
    }
    else {
   		 Titanium.include('globals.js');
   	
    }
    /////////////////////EVENT//////////
	var data = []; 
	var response;
    ////////////////////////////////////FUNTION///////////////////////
    ////////////////////////////////////////////////////////////
        
    var win = Titanium.UI.createWindow({
            id: 'SearchLecture',
            title: 'TÌM KIẾM',
            backgroundColor: '#FFF',
            barColor: '#414444',
            fullscreen: false
           
        });
       
    var egc = new globals.EventGarbageCollection(win);
	
	
	egc.addEventListener('LectureCategory:CreateCategoryDownload', function(data) {
		//	alert(data.dataLecture)
		Codestrong.navGroup.open(Codestrong.ui.CreateCategoryDownload({
    	    HeaderText:data.HeaderText
		}), 
		{
		    animated: true,
		    navBarHidden:true
		});				
    })
    
    egc.addEventListener('back_SearchLecture', function () {
    	Codestrong.navGroup.close(win, {
                        animated: true
        });
    	
	});
	////////////main_header///////////////////////////
	 var databutton_right=[
    	//{Id:1,Image:aps+'images/list_bullets.png',Image_:aps+'images/list_bullets_.png',tag:'Category'},
	    {Id:2,Image:aps+'images/account.png',Image_:aps+'images/account_.png',tag:'Login'},
	    {Id:3,Image:aps+'images/search.png',Image_:aps+'images/search_.png',tag:'Search'},
	    
	]
	
	
	var main_header=require('controls/main_header').main_header({
	 		backgroundImage: aps+'images/panel3.png',
	 		headertext:'Thầy trò Mobile: Tìm kiếm',
		    left: 0,
		    top: 0,
		    height:65,
		    width: Globals.platformWidth,
		    touchEnabled: true		,
		    databutton_right:databutton_right,
		  
		    imback:   aps+'images/back.png',
		    imback_:   aps+'images/back_.png',
		  	idWinParent:'SearchLecture',
		    
    })

	win.add(main_header);
	
	/////////TIM KIEM////////////
	var view_search = Ti.UI.createView({
		    top: main_header.top+main_header.height,
		    height:300,
		    //width: _args.width,
		    touchEnabled: true,
		});
	
   win.add(view_search);
   var txt_search = Ti.UI.createTextField({
		    top: 5,
		    left: 5,
		    right: 5,
		    borderColor:'Black',
		    borderWidth:1,
		    borderRadius:5,
		    hintText: 'Tên bài giảng cần tìm',
		    touchEnabled: true,
		    font: {fontFamily: 'Helvetica', fontSize: Ti.App.Properties.getString('fontsizeDialog')},
		    backgroundColor:'transparent',
		});
	
   view_search.add(txt_search);
   
  
  
  
   var ScrollViewMain = Ti.UI.createScrollView({
		top:view_search.height+view_search.top
	});
	var lbLoading = Ti.UI.createLabel({
		text:Globals.loading,
		color:'#1e6cc1',
		font:{
			fontSize:Ti.App.Properties.getString('fontsizeLarge'),
			fontWeight:'bold'
		},
	});
	ScrollViewMain.add(lbLoading)
	
	
	
	

    /////////////TABLE VIEW///////////////////////////
    var datatb=[]
  	var row = null;
    var data=[
    	{Id:1,Name:'Bài giảng đã tải'},
	    {Id:2,Name:'Bài giảng yêu thích'},
	    {Id:3,Name:'Bài giảng theo giáo viên'},
	    {Id:4,Name:'Bài giảng xem nhiều'},
	    {Id:5,Name:'Bài giảng miển phí'},
	]
    for (i = 0; i < data.length; i++) {
       row = Ti.UI.createTableViewRow({
				height:90,
				Id:data[i].Id,
				Name: data[i].Name,
				//backgroundColor:'Red',
				borderColor:'Red',
				
				//color:'Red',
			});
			
		
	   var info = Ti.UI.createLabel({
			text:data[i].Name,
			font:{
				fontSize:Ti.App.Properties.getString('fontsizeDefault'),
				fontWeight:'bold'
			},
			height:'auto',
			left:15,
			
			right: 15,
			color:'Black',
			touchEnabled:true,
			color:'#1b3e60'
			
		});
	
		row.add(info);
		datatb.push(row);
    }
   
  	var tbview = Ti.UI.createTableView({
  		
				top: 0,
				height: '100%',
				style:Titanium.UI.iPhone.TableViewStyle.PLAIN,
				backgroundColor:'#e5e4e4',
				data:datatb,
			    backgroundFocusedColor :'Red'
			});
	tbview.addEventListener('click', function(e)
	{
		
		if(e.rowData.Id==1)
		{
			//List dowloaded
			Ti.App.fireEvent('LectureCategory:CreateCategoryDownload',{HeaderText:e.rowData.Name})
		}
	});
	ScrollViewMain.add(tbview);
   
   
   
   
   
	

	win.add(ScrollViewMain);
 return win;
       
    };
})();